<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
</html>

<script>
  const canvas = document.createElement("canvas");
  canvas.width = 600;
  canvas.height = 400;
  document.body.append(canvas);
  const context = canvas.getContext("2d");

  // 参数分别是x和y还有半径r，，这里画的就是圆心是100，半径0，和半径100的一个同心圆
  const gradient = context.createRadialGradient(100, 100, 0, 100, 100, 100);

  gradient.addColorStop(0, "red");
  gradient.addColorStop(1, "blue");

  context.fillStyle = gradient;

  context.fillRect(0, 0, 200, 200);
</script>
